Creating Tools
BindAI tools expose Python application logic as executable capabilities. In V1, the simplest project tool is a Python function decorated with@tool.
Tools can be used for operations such as:
- Calculations
- Data transformation
- Business logic
- API calls
- Application-specific operations
- External integrations
Your First Tool
The simplest BindAI tool is a decorated Python function:@tool decorator turns the function into a BindAI tool.
The underlying implementation remains normal Python code.
Where to Put Tools
Project tools are normally kept in the project’stools directory.
For example:
Tool Names
The runtime uses the tool name when registering and resolving tools. For project tools, keep function names:- Short
- Descriptive
- Stable
- Specific to the operation
Parameters
Tool parameters come from the Python function interface. For example:ab
Type Annotations
Type annotations should be used whenever possible. For example:Optional Parameters
Python default values can be used when an operation has an optional input. For example:Tool Descriptions
Give tools clear descriptions. A docstring is useful for communicating the purpose of a tool:Returning Values
A tool can return normal Python values. For example:ToolResult
BindAI’s tool runtime usesToolResult to represent tool execution results.
A successful result can contain both the execution output and value:
ToolResult is part of the runtime execution contract.
When a tool is executed inside a workflow, the workflow runtime can preserve the result object in its variables.
Tool Failures
Tools can report operational failures throughToolResult.
For example:
- Credentials
- Access tokens
- Private connection information
- Sensitive application state
- Internal secrets
Tool Classes
BindAI also supports implementing tools asTool objects.
This is useful when the operation needs its own execution behavior or configuration.
A custom tool implements the BindAI tool interface and can expose a ToolDefinition.
Conceptually:
ToolDefinition
A BindAIToolDefinition describes the interface exposed by a tool.
It contains information such as:
- Name
- Description
- Parameters
payload parameter:
Execution Context
Tool implementations receive an execution context.
The context provides access to variables associated with the current execution.
For example:
ToolRegistry
BindAI uses aToolRegistry to register and resolve tools.
The registry allows the runtime to find a tool by name.
This is particularly important for persisted workflow definitions.
A workflow stores the tool reference:
echo to the actual registered tool.
Conceptually:
Project Tool Discovery
The Studio runtime discovers tools from the project. For example:Using a Tool in a Workflow
A project tool can be used by a workflow Tool node. For example:echo through the tool registry and executes it.
Tool Parameter Mapping
Workflow Tool nodes support parameter mapping. For example:Agent to Tool
Tools can be used after an Agent node. For example:Multiple Tools in a Project
A project can contain multiple tools. For example:Reusing Tools
The same project tool can be referenced by multiple workflows. For example:Connection-Backed Tools
BindAI V1 also supports tools backed by configured connections. The architecture is:webh produces a connection-backed tool:
Webhook Tool Example
A workflow can map a workflow variable to the Webhook tool’s payload:input contains:
Tools and Conditions
Tools can be followed by Condition nodes. For example:Tools and Loops
A Tool node can also participate in a workflow loop. For example:Tools and Parallel Execution
Tools can participate in parallel branches. For example:Tools and Memory
Tools and Memory have different responsibilities. Memory stores runtime or conversation information. Tools execute operations. They can be used together in a larger application:Tools and Knowledge
Tools can also be used alongside BindAI Knowledge. Knowledge provides configured project knowledge to agent execution. Tools provide executable operations. For example:API and External Services
Tools can call external services when the application requires it. For example, a project tool could wrap an HTTP API:- Authentication
- Input validation
- Response validation
- Error handling
- Appropriate network timeouts
File Operations
A tool can implement controlled file operations when an application requires them. For example:Database Operations
Database operations can also be wrapped in tools. For example:Tool Organization
As a project grows, organize tools by responsibility. For example:Read and Write Tools
It is useful to distinguish between read-oriented and state-changing operations. Read-oriented examples:Tool Security
Tools can execute real application operations and should therefore be treated as security boundaries. Important practices include:- Validate inputs.
- Apply authorization in application code.
- Protect credentials.
- Do not expose secrets in tool results.
- Restrict file-system access.
- Restrict database access.
- Keep destructive operations narrowly scoped.
- Validate data before writing to external systems.
Testing Tools
Tools should be tested independently where possible. For example, the underlying application logic can be tested normally:- Tool registration
- Tool discovery
- Tool parameters
- Successful execution
- Failed execution
- Tool results
- Workflow parameter mapping
- Connection-backed execution where applicable
Complete Project Example
A simple project can contain:tools/echo.py:
tools/increment.py:
ToolRegistry, maps the workflow value to the tool parameter, and executes the operation.
Best Practices
- Keep each tool focused on one responsibility.
- Use descriptive function names.
- Use Python type annotations.
- Write concise tool descriptions.
- Keep parameters explicit.
- Return predictable values.
- Keep tool results focused.
- Handle expected operational failures.
- Do not expose credentials.
- Validate external inputs.
- Apply authorization in application code.
- Restrict destructive operations.
- Test application logic independently.
- Test tool registration and workflow integration.
- Reuse common project tools.
- Use connections for reusable external integrations.
- Use workflows for multi-step orchestration.
Current V1 Scope
The verified BindAI V1 tool functionality includes:- Python project tools
- The
@tooldecorator ToolimplementationsToolDefinitionToolResultToolRegistry- Project tool discovery
- Workflow Tool nodes
- Tool parameter mapping
- Agent-to-Tool workflows
- Connection-backed Webhook tools
- Studio tool discovery
Summary
The simplest BindAI V1 tool is:ToolRegistry and executes it.
For external Webhook integrations, the same workflow mechanism can use a connection-backed tool:
